package com.vic.designpattern.patterns.c_behavioral.state.demo3;

/**
 * 中等状态
 * 分数大于等于60分小于90分为中等状态
 * @author victor
 */
public class MiddleState extends AbstractState {

    // 将上一次状态传递过来
    public MiddleState(AbstractState state) {
        // 实例化环境类
        hj = state.hj;
        stateName = "中等";
        score = state.score;
    }

    // 调整 hj 中的 state
    @Override
    public void adjustState() {
        if(score >= 90) {
            hj.setState(new HighState(this));
        } else if(score < 60) {
            hj.setState(new LowState(this));
        }
    }
}
